﻿@{
    Layout = null;
}
@model System.Collections.IEnumerable
<!DOCTYPE html>
@Html.Partial("LoadPanelPartial")
<html>
<head>
<title>用品初始化</title>
     @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    
    @Html.DevExpress().GetStyleSheets(
                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

    )
    @Html.DevExpress().GetScripts(
                    new Script { ExtensionType = ExtensionType.ListBox }
    )
    <style type="text/css">
        .num   
            {
            text-align : right;
            }
            
    
    </style>
    <script type="text/javascript">

        $(document).ready(function () {
            var hdjsAlert = $("#hdjsAlert").val();
            if (hdjsAlert != "") {
                alert(hdjsAlert);

            }
        });


        $(function () {
            ASPxClientComboBox.Cast("year").SetText($("#hdyear").val());
            ASPxClientComboBox.Cast("year").SetValue($("#hdyear").val());

        });


        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnSave":
                    {
                        //增加
                        form1.submit();
                        break;
                    }
            }
        }

        function ValueChange() {
            window.location.href = rootPath + "/Admin/OfficeItemYearBal/OfficeItemYearBalList?year=" + year.GetValue();           
         }


        function qty() {
            var itemNo = $("#hditemNo").val().split(',');
            for (var i = 0; i < itemNo.length; i++) {                
                var qty = document.getElementById("qty" + i).value;
                var price = document.getElementById("price" + i).value;
                var amount = document.getElementById("amount" + i).value;
                if (price == 0) {
                    if (qty == 0) {
                        document.getElementById("price" + i).value = 0;
                    } else {
                        document.getElementById("price" + i).value = amount / qty;
                    }
                }
                if (amount == 0) {
                    document.getElementById("amount" + i).value = qty * price;
                }                

                if (price == 0 && amount == 0) {
                    document.getElementById("price" + i).value = 0;
                    document.getElementById("amount" + i).value = 0;
                }

                if (price != 0 && amount != 0) {
                    document.getElementById("amount" + i).value = qty * price;
                 }
                              
            }
            
        }

        function price() {
            var itemNo = $("#hditemNo").val().split(',');
            for (var i = 0; i < itemNo.length; i++) {
                var qty = document.getElementById("qty" + i).value;
                if (qty == 0) {
                    document.getElementById("price" + i).value = 0;
                    document.getElementById("amount" + i).value = 0;
                 
                } else {
                    var price = document.getElementById("price" + i).value;
                    document.getElementById("amount" + i).value = qty * price;
                }
            }
         }

         function amount() {
             var itemNo = $("#hditemNo").val().split(',');
             for (var i = 0; i < itemNo.length; i++) {
                 var qty = document.getElementById("qty" + i).value;
                 var amount = document.getElementById("amount" + i).value;
                 if (qty == 0) {
                     document.getElementById("amount" + i).value = 0;
                     document.getElementById("price" + i).value = 0;
                 } else {
                     document.getElementById("price" + i).value = amount / qty;
                 }
             }
          }
    </script>

</head>

<body>
    <div>
        @Html.DevExpress().Menu(settings => 
        {
            settings.Name = "toolBarMenu";
            settings.ItemAutoWidth = false;
            settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
            settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
            settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

            settings.Items.Add(item =>
            {
                item.Name = "btnSave";
                item.Text = "保存";
                item.ItemStyle.ForeColor = System.Drawing.Color.Red;
                item.ClientEnabled = true;
                item.Visible = (bool)ViewData["visible"];
                item.Image.Url = Url.Content("~/Content/ControlImages/filesave.png");

            });
            settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
            settings.ItemLinkMode = ItemLinkMode.ContentBounds;
        }).GetHtml()
    </div>
    <div>
    @using (Html.BeginForm("Save", "OfficeItemYearBal", FormMethod.Post, new { id = "form1" }))
    {
        <table width="100%">
            <tr>
                <td align="right" width="90%">
                    年度:
                    </td>
                    <td>
                    @Html.DevExpress().ComboBox(settings =>
                    {
                        settings.Name = "year";
                        settings.Properties.TextField = "Text";
                        settings.Properties.ValueField = "Value";
                        settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                        settings.Properties.ClientSideEvents.ValueChanged = "function(s,e){ValueChange()}";
                    }).BindList(ViewData["yyyy"]).GetHtml()
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    @Html.Raw(ViewData["strHtml"].ToString())
                </td>
            </tr>
        </table>
        
        @Html.Hidden("hditemNo", ViewData["itemNo"])
        @Html.Hidden("hdjsAlert", ViewData["jsAlert"]);
        @Html.Hidden("hdyear", ViewData["year"])
    }    
    </div>
     <script type="text/javascript">
         lp.Hide();
    </script>
</body>
</html>
